import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useSettingStore = defineStore('setting', () => {
    const sysTheme = ref('')
    const nowTheme = ref('')
    const themeSet = ref('auto')
    const defStar = ref(['2','3','4'])
    function setAutoTheme(theme){
        sysTheme.value = theme
        if(themeSet.value == 'auto'){
            setTheme(theme)
        }
    }
    function setTheme(theme){
        nowTheme.value = theme
        document.body.setAttribute("theme-mode", theme);
    }
    function syncSysTheme(){
        nowTheme.value = sysTheme.value
    }
    return {sysTheme,nowTheme,themeSet,defStar,setAutoTheme,setTheme,syncSysTheme}
},{
    persist: true,
})
